/*
 * @Author: yangzonglong
 * @Date: 2021-03-08 15:27:24
 * @version: v1.0.0
 * @Descripttion: 
 * @LastEditors: yangzonglong
 * @LastEditTime: 2021-06-17 14:28:31
 * @Auditor: 
 */
import React from 'react';
import FormItemController from './../components/FormItemController';
import OptionSetting from '../components/optionSetting/OptionSetting';
import useControlOptions from '../../hooks/useControlOptions';
import { RadioProps } from './Radio';

const Controller = () => {

  const { options, changeFormItemProps, changeControlProps } = useControlOptions<RadioProps>('radioProps');

  return (
    <FormItemController hidePlaceholder onChange={changeFormItemProps} options={options?.formItemProps} >
      <OptionSetting editInModal showDefault otherProps="radioProps" changeControlProps={(propsKey, value, flag) => {
        changeControlProps('radioProps', {
          ...value,
          defaultValue: value?.dataSource?.filter((item: any) => item.checked)?.[0]?.value
        }, flag);
      }}
        options={options?.radioProps} />
    </FormItemController>
  );
};

export default Controller;